package com.itheima.demo1;

import java.util.*;

public class PokerGame {
    static HashMap<Integer,String> hm=new HashMap<>();
    static ArrayList<Integer> list = new ArrayList<>();

    static int number = 1;

    //装牌
    static {
        String[] a = {"♦","♣","♥","♠"};
        String[] b = {"3","4","5","6","7","8","9","10","J","Q","K","A","2"};


        for (String s : b) {

            for (String s1 : a) {
                hm.put(number,s + s1);
                list.add(number);
                number++;
            }
        }

        hm.put(number,"小王");
        list.add(number);
        number++;

        hm.put(number,"大王");
        list.add(number);
    }


    public PokerGame(){
        //洗牌
        Collections.shuffle(list);

        //发牌
        TreeSet<Integer> lode = new  TreeSet<>();
        TreeSet<Integer> playgame1 = new  TreeSet<>();
        TreeSet<Integer> playgame2 = new  TreeSet<>();
        TreeSet<Integer> playgame3 = new  TreeSet<>();

        for (Integer i : list) {
            if (i <= 2){
                lode.add(i);
            }

            if (i %3 ==0){
                playgame1.add(i);
            }else if (i %3 == 1){
                playgame2.add(i);
            }else {
                playgame3.add(i);
            }
        }

        //看牌
        lookPoker("zhangsan",playgame1);
        lookPoker("lisi",playgame2);
        lookPoker("wangwu",playgame3);

    }

    public void lookPoker(String name ,TreeSet<Integer> ts){
        System.out.print(name + ": ");
        for (Integer t : ts) {
            String s = hm.get(t);
            System.out.print(s+ ",");
        }
        System.out.println();
    }

}
